package com.breomedia.social.friendfeed

class FriendFeedTest extends GroovyTestCase {
	
	static String TEST_NICKNAME = "" // Test Nickname
	static String TEST_NICKNAME_2 = "" // 2nd Test Nickname (used to test multi-user method calls)
	static String TEST_ROOM = "grails"
	static String TEST_NICKNAME_REMOTE_KEY = "" // the remote key bound to TEST_NICKNAME
	
	// PUBLISHING TEST VALUES
	static String TEST_MESSAGE = "Test from FriendFeed Groovy API"
	static String TEST_COMMENT = "First Post!"
	static String TEST_LINK = "http://labs.breomedia.com"
	
	void testPublicFeed() {
		println "**** FriendFeed Public Feed Test ****"
		println new FriendFeed().fetchPublicFeed();
	}

	void testFetchUserFeed() {
		println "**** FriendFeed User Feed Test ****"
		
		def ff = new FriendFeed();
		
		println "XML OUTPUT == " + ff.fetchUserFeed(FriendFeedTest.TEST_NICKNAME);
		println "JSON OUTPUT == " + ff.fetchUserFeed(FriendFeedTest.TEST_NICKNAME, "json");
		println "RSS OUTPUT == " + ff.fetchUserFeed(FriendFeedTest.TEST_NICKNAME, "rss");
		println "ATOM OUTPUT == " + ff.fetchUserFeed(FriendFeedTest.TEST_NICKNAME, "atom");
	}
	
	void testFetchUserComments() {
		println "**** FriendFeed User Comments Test ****"
		println new FriendFeed().fetchUserComments(FriendFeedTest.TEST_NICKNAME);
	}
	
	void testFetchUserLikes() {
		println "**** FriendFeed User Likes Test ****"
		println new FriendFeed().fetchUserLikes(FriendFeedTest.TEST_NICKNAME);
	}
	
	void testFetchUserDiscussions() {
		println "**** FriendFeed User Discussions Test ****"
		println "XML OUTPUT == " + new FriendFeed().fetchUserDiscussions(FriendFeedTest.TEST_NICKNAME);
	}
	
	void testFetchMultiUserFeed() {
		println "**** FriendFeed Multi-User Feed Test ****"
		
		def ff = new FriendFeed();
		def nicks = [FriendFeedTest.TEST_NICKNAME, FriendFeedTest.TEST_NICKNAME_2]
		
		println "XML OUTPUT == " + ff.fetchMultiUserFeed(nicks);
		println "ATOM OUTPUT == " + ff.fetchMultiUserFeed(nicks, "atom");
	}
	
	void testFetchRoomEntries() {
		println "**** FriendFeed Room Entries Test ****"
		println "XML OUTPUT == " + new FriendFeed().fetchRoomEntries(FriendFeedTest.TEST_ROOM);
	}
	
	void testSearch() {
		println "**** FriendFeed Search Test ****"
		println "XML OUTPUT == " + new FriendFeed().search("proverbial", "danker");
	}
	
	void testServices() {
		println "**** FriendFeed Services Test ****"
		println "XML OUTPUT == " + new FriendFeed().services();
	}
	
	void testFetchUserHomeFeed() {
		println "**** FriendFeed User Home Test (Authenticated) ****"
		println "XML OUTPUT == " + 
			new FriendFeed(nickname:FriendFeedTest.TEST_NICKNAME, 
				remoteKey:FriendFeedTest.TEST_NICKNAME_REMOTE_KEY).fetchUserHomeFeed();
	}
	
	//
	// PROFILE TESTS ==========================================================
	//
	
	void testGetUserProfile() {
		println "**** FriendFeed User Profile Test ****"
		println "JSON OUTPUT == " + new FriendFeed().getUserProfile(FriendFeedTest.TEST_NICKNAME, "json");
	}
	
	void testGetMultiUserProfiles() {
		println "**** FriendFeed Multiple User Profiles Test ****"
		
		def ff = new FriendFeed();
		def nicks = [FriendFeedTest.TEST_NICKNAME, FriendFeedTest.TEST_NICKNAME_2]
		
		println "JSON OUTPUT == " + ff.getMultiUserProfile(nicks, "json");
		println "XML OUTPUT == " + ff.getMultiUserProfile(nicks);
	}
	
	void testGetRoomProfile() {
		println "**** FriendFeed Room Profile Test ****"
		println "JSON OUTPUT == " + new FriendFeed().getRoomProfile(FriendFeedTest.TEST_ROOM, "json");
	}
	
	//
	// PUBLISHING TESTS =======================================================
	// All test methods below require authentication
	
	/*
	void testPublishMessage() {
		println "**** FriendFeed Publish Message Test ****"
		println new FriendFeed(nickname:FriendFeedTest.TEST_NICKNAME, 
			remoteKey:FriendFeedTest.TEST_NICKNAME_REMOTE_KEY).publishMessage(FriendFeedTest.TEST_MESSAGE, 
				FriendFeedTest.TEST_COMMENT);
	}
	
	void testPublishLink() {
		println "**** FriendFeed Publish Link Test ****"
		println new FriendFeed(nickname:FriendFeedTest.TEST_NICKNAME, 
				remoteKey:FriendFeedTest.TEST_NICKNAME_REMOTE_KEY).publishLink(FriendFeedTest.TEST_MESSAGE, 
						FriendFeedTest.TEST_LINK, FriendFeedTest.TEST_COMMENT);
	}
	*/
}